package com.community.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.community.entity.LampLog;
import com.community.service.LampLogService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (LampLog)表控制层
 *
 * @author makejava
 * @since 2021-12-06 10:34:41
 */
@Controller
@RequestMapping("lampLog")
public class LampLogController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private LampLogService lampLogService;

    @RequestMapping("lamploglist")
    public String tolist() {
        return "lamp_loglist";
    }

    /**
     * 分页查询所有数据
     *
     * @param page    分页对象
     * @param lampLog 查询实体
     * @return 所有数据
     */
    @GetMapping("list")
    @ResponseBody
    public R selectAll(Page<LampLog> page, LampLog lampLog) {
        QueryWrapper<LampLog> wrapper = new QueryWrapper<>(lampLog);
        wrapper.orderByDesc("lamp_date");
        return success(this.lampLogService.page(page, wrapper));
    }
}

